package com.cmc.cloud.cmclink.doc.controller.admin.multimodaltransport;

import com.cmc.cloud.cmclink.doc.api.document.emums.SoDataSourceEnum;
import com.cmc.cloud.cmclink.doc.constants.UrlConstants;
import com.cmc.cloud.cmclink.doc.service.MultiManifestService;
import com.cmc.cloud.cmclink.doc.service.manifest.ManifestService;
import com.cmc.cloud.cmclink.doc.vo.multimodaltransport.multimanifest.MultiManifestReqVO;
import com.cmc.cloud.cmclink.doc.vo.multimodaltransport.multimanifest.MultiManifestRespVO;
import com.cmes.framework.biz.advice.annotations.UseResponsePropertyAdvice;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import com.cmes.framework.security.core.util.SecurityFrameworkUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author lzp
 * @date 2025/10/25 13:18
 * @description
 */
@Tag(name = "管理后台 - 多联出口预配仓单")
@RestController
@Validated
@RequestMapping(UrlConstants.APPLICATION_URL + "/multi/manifest")
public class MultiManifestController {

    @Resource
    private MultiManifestService multiManifestService;


    @Operation(description = "多联出口预配仓单查询")
    @PostMapping("/search")
    @UseResponsePropertyAdvice
    @PreAuthorize("@ss.hasPermission('doc:manifestMulti:search')")
    public CommonResult<PageResult<MultiManifestRespVO>> searchMultiManifestInfo(@Valid @RequestBody MultiManifestReqVO multiManifestReqVo) {
        return CommonResult.success(multiManifestService.searchMultiManifestInfo(multiManifestReqVo));
    }

    @Operation(summary = "批量创建舱单主来源SO")
    @PostMapping("/batchCreateMasterFromSo")
    @PreAuthorize("@ss.hasPermission('doc:manifestMulti:createMaster')")
    public CommonResult<List<Long>> batchCreateMasterFromSo(@RequestBody List<Long> soIdList) {
        return CommonResult.success(multiManifestService.batchCreateMasterFromSo(soIdList));
    }
}
